package controleur;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import modele.CKModel;
import modele.Knowledge;
import vue.VueEditeurCK;

public class ControleAddKnowledge implements ActionListener {

	CKModel<String,String> _modele;
	VueEditeurCK _vue;
	
	
	public ControleAddKnowledge(CKModel<String,String> modele, VueEditeurCK vue){
		_modele = modele;
		_vue = vue;
	}
	
	public void actionPerformed(ActionEvent e) {
		Knowledge<String> knowledge = new Knowledge<String>(_modele.getKSpace().size(), _vue.getPanelAddK().getTextK());
		_modele.getKSpace().add(knowledge);
		
		if(_vue.getPanelAddK().getRdbK().isSelected()){
			_modele.addLink(_modele.findConceptFromId(_vue.getPanelAddK().getCmbC().getSelectedIndex()), _modele.getKSpace().elementAt(_modele.getKSpace().size() - 1));
		}
		
		_vue.getEditorFrame().paint(_vue.getEditorFrame().getGraphics());
		_vue.dessiner();
		
		
	}

}
